<?php
if (!defined('WEB_ROOT')) {
	exit;
}

// make sure a product id exists
if (isset($_GET['id']) && $_GET['id'] > 0) {
	$id = $_GET['id'];
} else {
	// redirect to index.php if product id is not present
	header('Location: index.php');
}

$sql = "SELECT dt.id, madt, tendt, tomtat_dt, noidung_dt, namthuchien, ngaybatdau, ngayketthuc, kinhphi, ldt.tenloai, cth.tencap, tt.tentt, dv.tendv, nn.tennn
        FROM detai dt join loaidetai ldt on dt.loaidt_id = ldt.id join capthuchien cth on dt.cap_id = cth.id join trangthai tt on dt.tt_id = tt.id join donvi dv on dt.dv_id = dv.id join nhomnganh nn on dt.nn_id = nn.id
		WHERE dt.id = $id";
$result = mysql_query($sql) or die('Không lấy được thông tin đề tài. ' . mysql_error());

$row = mysql_fetch_assoc($result);
extract($row);

?>
<div class="onecolumn">
	<div class="header">
		<span>Thông tin đề tài</span>
	</div>
	<br class="clear"/>
	<div class="content">

		<form action="processTopic.php?action=addTopic" method="post" enctype="multipart/form-data" name="frmAddTopic" id="frmAddTopic">
		 <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable">
		  <tr> 
			   <td width="360" class="label">Mã đề tài</td>
			   <td class="content" colspan="5"><?php echo $madt; ?></td>
		  </tr>
		  <tr> 
			   <td width="360" class="label">Tên đề tài</td>
			   <td class="content" colspan="5"><b><?php echo $tendt; ?></b></td>
		  </tr>
		  <tr> 
			   <td width="360" class="label">Năm thực hiện</td>
			   <td class="content"><?php echo $namthuchien; ?></td>
			   <td width="259" class="label">Ngày bắt đầu</td>
			  <td width="161" class="content"><?php echo $ngaybatdau; ?></td>
			   <td width="123" class="label">Ngày kết thúc</td>
			  <td width="210" class="content"><?php echo $ngayketthuc; ?></td>
		  </tr>
		  <tr> 
			   <td width="360" class="label">Kinh phí</td>
			  <td width="120" class="content"><?php echo $kinhphi; ?></td>
			   <td width="259" class="label">Trạng thái</td>
			  <td class="content" colspan="0"><?php echo $tentt; ?></td>
				<td width="259" class="label">Cấp thực hiện</td>
				<td class="content" colspan="3"><?php echo $tencap; ?></td>
		  </tr>
		  <tr> 
			   <td width="360" class="label">Loại đề tài</td>
			   <td class="content" colspan="0" width="200"><?php echo $tenloai; ?> </td>
				<td width="360" class="label">Nhóm ngành</td>
			   <td class="content" colspan="3" width="200"> <?php echo $tennn; ?></td>
		  </tr>
		  <tr>
					<td width="360" class="label">Đơn vị</td>
			   <td class="content" colspan="5"><?php echo $tendv; ?> </td>
		  </tr>
		   <tr> 
			   <td width="360" class="label">Tóm tắt đề tài</td>
			   <td class="content" colspan="5"><?php echo $tomtat_dt; ?>
			   </td>
		  </tr>
		  <tr> 
			   <td width="360" class="label">Nội dung đề tài</td>
			   <td class="content" colspan="5">
			   			<?php 
							//echo $noidung_dt;
							$arr = explode(",", $noidung_dt);
							//$ngayketthuc = $arr[2] . "-" . $arr[1] . "-" . $arr[0];
							for ($i = 0; $i < count($arr); $i++){
								echo "<a href='../../data/".$arr[$i]."'>".$arr[$i]."</a></div><br>";
							}
						?>
			   </td>
		  </tr>
		  <tr> 
			   <td width="360" class="label">Tác giả thực hiện</td>
			   <td class = "content" colspan="5"> 	
					<?php 
			   			$sqltg = "	SELECT hotentg, tenvt from detai dt, tacgia_detai tgd, tacgia tg, vaitro vt
									WHERE dt.id = tgd.dt_id and tgd.tg_id = tg.id and tgd.vt_id = vt.id and dt.id = $id";
						$result2 = dbQuery($sql_nth);
						$tg  = '';
						if (mysql_num_rows($result2)<>0){
							$i = 0; 
							while ($row = mysql_fetch_array($result2)){
								$i= $i + 1; 
								$hotentg = $row["hotentg"];
								$tenvt = $row["tenvt"];
								$tg = "kkhhhhh";//$tg . $hotentg."(".$vaitro.")";
							}
						}
						echo $tg;  	
					?>	
			   </td>
		  </tr>
		 </table>
		 </table>
		 <p align="center"> 
		  <input name="btnModifyProduct" type="button" id="btnModifyTopic" value="Sửa thông tin đề tài" onClick="window.location.href='index.php?view=modify&id=<?php echo $id; ?>';" class="box">
		  &nbsp;&nbsp;
		  <input name="btnBack" type="button" id="btnBack" value=" Trở lại " onClick="window.history.back();" class="box">
		 </p>
		</form>
	</idv>
</div>
